/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSRotate.h
 *
 *  Created on: 2010/03/05
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#ifndef RSROTATE_H_
#define RSROTATE_H_

#include "RSTransformationElement.h"
#include <QVector3D>
#include <QQuaternion>

namespace Realsphere {

    class RSRotate: public Realsphere::RSTransformationElement {
        Q_OBJECT
        public:
            RSRotate ( const QString& rScopeId = QString::null );
            virtual ~RSRotate();

        public:
            QVector3D               Axis () const;
            qreal                   Angle () const;
            QQuaternion             Quaternion () const;

        public slots:
            void                    SetAxis ( const QVector3D& rAxis, bool rEmit = true );
            void                    SetAngle ( qreal rAngle, bool rEmit = true );
            void                    SetQuaternion ( const QQuaternion& rQuaternion, bool rEmit = true );
            void                    SetRotation ( const QVector3D& rAxis, qreal rAngle, bool rEmit = true  );

            void                    ApplyRotationR ( const QVector3D& rAxis, qreal rAngle );
            void                    ApplyRotationL ( const QVector3D& rAxis, qreal rAngle );

            void                    ApplyRotationR ( const QQuaternion& rQuaternion );
            void                    ApplyRotationL ( const QQuaternion& rQuaternion );

            void                    ApplyRotationR ( qreal rPitch, qreal rYaw, qreal rRoll );
            void                    ApplyRotationL ( qreal rPitch, qreal rYaw, qreal rRoll );

        signals:
            void                    AxisChanged ( const QVector3D& rAxis );
            void                    AngleChanged ( qreal rAngle );

        protected:
            void                    WriteElementData ( QXmlStreamWriter* rXmlWriter );
            void                    UpdateTransformation ();

        private:
            QVector3D               mAxis;
            qreal                   mAngle;
            QQuaternion             mQuaternion;
    };

}

#endif /* RSROTATE_H_ */
